<?php
namespace hc;
class session{
	private $session_class;
	public static function init(){
				$s_config=C('session');
				$c_fonfig=C('cookie');
		 		if(isset($s_config['use_trans_sid'])) {
            ini_set('session.use_trans_sid', $s_config['use_trans_sid'] ? 1 : 0);
      	}
       	//session 不自动开起；
        if(isset($s_config['auto_start'])) {
            ini_set('session.auto_start', 0);
        }
        if (isset($c_fonfig['path'])) {
            session_save_path($c_fonfig['path']);
        }
        if (isset($c_fonfig['domain'])) {
            ini_set('session.cookie_domain',$c_fonfig['domain']);
        }
        if (isset($c_fonfig['expire'])) {
            ini_set('session.gc_maxlifetime', $c_fonfig['expire']);
            ini_set('session.cookie_lifetime',$c_fonfig['expire']);
        }
        if (isset($c_fonfig['secure'])) {
            ini_set('session.cookie_secure', $c_fonfig['secure']);
        }
        if (isset($c_fonfig['httponly'])) {
            ini_set('session.cookie_httponly',$c_fonfig['httponly']);
        }
        if (isset($c_fonfig['use_cookies'])) {
            ini_set('session.use_cookies', $c_fonfig['use_cookies'] ? 1 : 0);
        }
        if (isset($c_fonfig['cache_limiter'])) {
            session_cache_limiter($c_fonfig['cache_limiter']);
        }
        if (isset($c_fonfig['cache_expire'])) {
            session_cache_expire($c_fonfig['cache_expire']);
        }
		$session_type=C('session_type');
		if(!empty($session_type)){
			$class='\\sess\\session_'.$session_type;
			ini_set('session.save_handler','user');
			//session_module_name('user');
			if (!class_exists($class) || !session_set_save_handler(new $class())) {
				msg_error('不存在'.$class);
			}
		}
		if($s_config['auto_start']){if(!session_id()){session_start();}}
	}
}
//訪問session::inint(); 銷毀：session_unset();session_destroy();
?>
